<?php

namespace App\Console\Commands;

use App\Models\DormMeter;
use Illuminate\Console\Command;

class DormMeterPatch extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dorm_meter:patch';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'patch the expire date of inactive dorm meter';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        \DB::unprepared("update dorm_meters set expire_date=last_reading_date where active=0");
        \DB::unprepared("update dorm_meters set install_date=created_at");
        $this->info('patch finished');
    }
}
